home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / perl5 / Tie::Scalar.z / Tie::Scalar
Encoding:
Text File  |  1998-10-30  |  3.7 KB  |  133 lines

  1.  
  2.  
  3.  
  4. TTTTiiiieeee::::::::SSSSccccaaaallllaaaarrrr((((3333))))                                                  TTTTiiiieeee::::::::SSSSccccaaaallllaaaarrrr((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      Tie::Scalar, Tie::StdScalar - base class definitions for tied scalars
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.          package NewScalar;
  13.          require Tie::Scalar;
  14.  
  15.          @ISA = (Tie::Scalar);
  16.  
  17.          sub FETCH { ... }           # Provide a needed method
  18.          sub TIESCALAR { ... }       # Overrides inherited method
  19.  
  20.  
  21.          package NewStdScalar;
  22.          require Tie::Scalar;
  23.  
  24.          @ISA = (Tie::StdScalar);
  25.  
  26.          # All methods provided by default, so define only what needs be overridden
  27.          sub FETCH { ... }
  28.  
  29.  
  30.          package main;
  31.  
  32.          tie $new_scalar, 'NewScalar';
  33.          tie $new_std_scalar, 'NewStdScalar';
  34.  
  35.  
  36. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  37.      This module provides some skeletal methods for scalar-tying classes. See
  38.      the _p_e_r_l_t_i_e manpage for a list of the functions required in tying a
  39.      scalar to a package. The basic TTTTiiiieeee::::::::SSSSccccaaaallllaaaarrrr package provides a new method,
  40.      as well as methods TIESCALAR, FETCH and STORE. The TTTTiiiieeee::::::::SSSSttttddddSSSSccccaaaallllaaaarrrr package
  41.      provides all the methods specified in  the _p_e_r_l_t_i_e manpage. It inherits
  42.      from TTTTiiiieeee::::::::SSSSccccaaaallllaaaarrrr and causes scalars tied to it to behave exactly like the
  43.      built-in scalars, allowing for selective overloading of methods. The new
  44.      method is provided as a means of grandfathering, for classes that forget
  45.      to provide their own TIESCALAR method.
  46.  
  47.      For developers wishing to write their own tied-scalar classes, the
  48.      methods are summarized below. The the _p_e_r_l_t_i_e manpage section not only
  49.      documents these, but has sample code as well:
  50.  
  51.      TIESCALAR classname, LIST
  52.           The method invoked by the command tie $scalar, classname. Associates
  53.           a new scalar instance with the specified class. LIST would represent
  54.           additional arguments (along the lines of the _A_n_y_D_B_M__F_i_l_e manpage and
  55.           compatriots) needed to complete the association.
  56.  
  57.      FETCH this
  58.           Retrieve the value of the tied scalar referenced by _t_h_i_s.
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. TTTTiiiieeee::::::::SSSSccccaaaallllaaaarrrr((((3333))))                                                  TTTTiiiieeee::::::::SSSSccccaaaallllaaaarrrr((((3333))))
  71.  
  72.  
  73.  
  74.      STORE this, value
  75.           Store data _v_a_l_u_e in the tied scalar referenced by _t_h_i_s.
  76.  
  77.      DESTROY this
  78.           Free the storage associated with the tied scalar referenced by _t_h_i_s.
  79.           This is rarely needed, as Perl manages its memory quite well. But
  80.           the option exists, should a class wish to perform specific actions
  81.           upon the destruction of an instance.
  82.  
  83. MMMMOOOORRRREEEE IIIINNNNFFFFOOOORRRRMMMMAAAATTTTIIIIOOOONNNN
  84.      The the _p_e_r_l_t_i_e manpage section uses a good example of tying scalars by
  85.      associating process IDs with priority.
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.